package com.bk.controller.loan;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.bk.entity.CardInfo;
import com.bk.entity.LoanInfo;
import com.bk.entity.UserInfo;
import com.bk.service.loan.LoanInfoService;
import com.bk.util.ReturnUtil;
import com.bk.vo.LoanInfoUserVo;

@RestController
public class LoanController {

	@Autowired
	private LoanInfoService loanInfoService;
	
	
	@PostMapping("/queryCreditByUid") /**查询用户信用级别 */
	public ReturnUtil<UserInfo> queryCreditByUid(@RequestParam("uid") String uid,@RequestParam("name") String name,@RequestParam("accountUid") String repaymentAccountId) {
		ReturnUtil<UserInfo> rc = loanInfoService.queryCreditByUid(uid,name,repaymentAccountId);
		return rc;
	}
	
	@PostMapping("/approvalLoan") /**贷款申请提交 */
	public ReturnUtil<String> approvalLoan(LoanInfo loanInfo) {
		ReturnUtil<String> rc = loanInfoService.approvalLoan(loanInfo);
		return rc;
	}
	
	/**获取所有等待审批的贷款记录*/
	@PostMapping("/getAllWaitPassLoanInfo")
	public ReturnUtil<LoanInfo> getAllWaitPassLoanInfo() {
		ReturnUtil<LoanInfo> rc = loanInfoService.getAllWaitPassLoanInfo();
		return rc;
	}
	
	/**获取所有等待审批的贷款记录*/
	@PostMapping("/getAllNoPassLoanInfo")
	public ReturnUtil<LoanInfo> getAllNoPassLoanInfo() {
		ReturnUtil<LoanInfo> rc = loanInfoService.getAllNoPassLoanInfo();
		return rc;
	}
	

	
	/**
	 * 
	 * @param uid  身份证
	 * @param loanStatu  审批状态
	 * @param loanNum 贷款记录序列 
	 * @param flag    1为通过申请   -1申请驳回
	 * @return 
	 * @desc 贷款审批通过还是驳回
	 */
	@PostMapping("/isPassOrRefuseLoan/{flag}")
	public ReturnUtil<String> isPassOrRefuseLoan(@RequestParam("uid") String uid,@RequestParam("loanNum") int loanNum,@PathVariable("flag") int flag) {
		ReturnUtil<String> rc = loanInfoService.isPassOrRefuseLoan(uid,loanNum,flag);
		return rc;
	}
}
